package com.Ritany3.subject.domain.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * 线程池的Config管理
 */
@Configuration
public class ThreadPoolConfig {

    @Bean(name = "labelTreadPool")
    public ThreadPoolExecutor getLabelTreadPool(){
            return new ThreadPoolExecutor(20,100,
   5, TimeUnit.SECONDS,new LinkedBlockingDeque<>(40),
//                    Executors.defaultThreadFactory(),
                    new CustomNameThreadFactory("label"),
                    new ThreadPoolExecutor.CallerRunsPolicy());
    }

}
